<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
	<title>WeUI</title>
	<link rel="stylesheet" href="../css/weui.css"/>
	<link rel="stylesheet" href="../css/perInfo.css"/>
	<script src="../js/jquery-2.1.1.min.js"></script>
	<script src="../js/jquery.form.min.js"></script>
	<script src="../js/main.js"></script>
	<script src="../layer/layer.js"></script>
	<title>成果提交</title>
</head>

<body>


<div id="d" style="padding-bottom:10%;width:100%;height:0;margin-top: 1rem;background-color: black;margin-top: 0px;">
	<div style="width:70%;margin:auto auto;">
		<img src="../img/index/top.png" style="height: auto;width:100%; margin:auto auto;"/>
	</div>
</div>

<form id="ajForm" method="post">

	<div class="weui-cells weui-cells_form">
		<div class="weui-cell">
			<div class="weui-cell__hd"><label class="weui-label">标题</label></div>
			<div class="weui-cell__bd">
				<input class="weui-input" name="title" type="text" placeholder="请输入标题">
			</div>
		</div>

		<div class="weui-cell">
			<div class="weui-cell weui-cell_select">
				<div class="weui-cell__hd">行动分类</div>
				<div class="weui-cell__bd">
					<select class="weui-select" name="aid">

					</select>
				</div>
			</div>
		</div>

		<input type="hidden" name="rid">

		<div class="weui-cell">
			<div class="weui-cell__hd"><label class="weui-label">需求编号</label></div>
			<div class="weui-cell__bd">
				<input class="weui-input" name="did" type="number" pattern="[0-9]*" placeholder="请输入需求编号">
			</div>
		</div>

		<div class="weui-cell">
			<div class="weui-cell__hd"><label class="weui-label">资源编号</label></div>
			<div class="weui-cell__bd">
				<input class="weui-input" name="sid" type="number" pattern="[0-9]*" placeholder="请输入资源编号">
			</div>
		</div>


		<div class="weui-cell">
			<div class="weui-cell__hd"><label class="weui-label">对接内容</label></div>
			<div class="weui-cell__bd">
				<input class="weui-input" type="text" name="content" placeholder="请输入服务内容">
			</div>
		</div>

		<div class="weui-cell">
			<div class="weui-cell__hd"><label class="weui-label">经济效益</label></div>
			<div class="weui-cell__bd">
				<input class="weui-input" type="number" step="0.01" name="benefit" placeholder="单位：万元">
			</div>
		</div>

		<div class="weui-cell">
			<div class="weui-cell__hd"><label class="weui-label">对接开始时间</label></div>
			<div class="weui-cell__bd">
				<input class="weui-input" name="begin" type="date">
			</div>
		</div>

		<div class="weui-cell">
			<div class="weui-cell__hd"><label class="weui-label">对接结束时间</label></div>
			<div class="weui-cell__bd">
				<input class="weui-input" name="end" value="2018/09/12" type="date">
			</div>
		</div>

		<div class="weui-btn-area">
			<input type="submit" class="weui-btn weui-btn_primary" id="showTooltips" value="修改"/>
		</div>
	</div>
</form>
<script>
    $.ajaxSetup({
        xhrFields: {
            withCredentials: isCrossDomain
        }
    });
    $(function () {
        $.get(mainurl+"get/achievements",function (data) {
            if(checkData(data)) {
                for(var i=0; i<data.data.length; i++) {
                    var d = data.data[i];
                    $("select[name='aid']").append("<option value="+d.aid+">"
                        + d.achievement + "</option>");
                }
                if($.getUrlParam('id')!=null) {
                    $.post(mainurl+"skill/getResult",{rid:$.getUrlParam('id')},function (data,status) {
                        if(checkData(data)){
                            setDataByName(data.data);
                        }
                    })
                } else {
                    errorInfo("请求非法");
                }
            }
        });

        var options = {
            // 规定把请求发送到那个URL
            url: mainurl+"skill/setResult",
            // 请求方式
            type: "post",
            // 服务器响应的数据类型
            dataType: "json",
            beforeSubmit: function (formData, jqForm, options) {
                for(i=0; i<formData.length; i++) {
                    if(formData[i].value==''){
                        warnInfo("参数不能为空");
                        return false;
                    }
                }
                return true;
            },
            // 请求成功时执行的回调函数
            success: function(data, status, xhr) {
                if(checkData(data)) {
                    successInfo("修改成功");
                    window.history.back(-1);
                }
            }
        };
        $("#ajForm").ajaxForm(options);
    })
</script>
</body>

</html>